package cn.com.io.day20151214.control;

import cn.com.io.day20151214.pojo.Light;

import java.io.*;

/**
 * 自定义序列（五）
 */
public class LightTest {
    public static void main(String[] args) throws IOException {
        ObjectOutputStream oos = null;
        ObjectInputStream ois = null;

        try {
            oos = new ObjectOutputStream(new FileOutputStream("light.txt"));
            Light light = new Light("越丰照明",200,"100");
            oos.writeObject(light);

            ois = new ObjectInputStream(new FileInputStream("light.txt"));
            Light lightGet = (Light)ois.readObject();
            System.out.println(lightGet.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            if(oos !=null){
                oos.close();
            }
            if(ois !=null){
                ois.close();
            }
        }
    }
}
